package _base;
import java.sql.*;

public class Connector implements AutoCloseable {
	private Connection _con;
	private Statement _stmt;
	
    public void connect(String dbPath) throws ClassNotFoundException, SQLException
    {
    	Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
		String connURL="jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" + dbPath + ";";
		_con = DriverManager.getConnection(connURL);
    }
    
    public void execute(String statement) throws SQLException
    {
    	_stmt = _con.createStatement();
   		_stmt.execute(statement);
    }
    
    public ResultSet executeWithResult(String statement) throws SQLException
    {
   		_stmt = _con.createStatement();
   		_stmt.execute(statement);
		return _stmt.getResultSet();
    }

    @Override
    public void close() throws SQLException
    {
		_stmt.close();
		_con.close();
    }
}